<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9-预定义类</title>
</head>
<body>
    <script>
        //\d 匹配[0-9]
        //\s 匹配空格
        //\w 匹配任意英文字符[a-zA-Z0-9]
        //029-12345678 或者 0530-1234567
        var reg = /^\d{3}-\d{8}|\d{4}-\d{7}$/;
        console.log(reg.test('029-12345679'));
        console.log(reg.test('0291-1234566'));

        var reg2 = /^\d{3,4}-\d{7,8}$/;

        //手机号验证 11位 13,14,15,17,18开头
        var regm = /^1[3|4|5|7|8]\d{9}$/;
        console.log(regm.test('18291823059'));

    </script>
</body>
</html>